/**
 * 
 */
package cheme.ProcessEditor.Tools;

import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gef.requests.CreationFactory;

import cheme.ProcessModel.ProcessModelConstants;


/**
 * @author Jonathan
 *
 */
public class CreateGroupRequest extends ChangeBoundsRequest
{
	private Rectangle subProcessBounds;
	
	private CreationFactory factory;
	
	private Object newObject;
	
	private EditPart targetEditPart;
	
	/**
	 * 
	 */
	public CreateGroupRequest()
	{
		super(ProcessModelConstants.REQ_CREATE_GROUP);
	}

	public Rectangle getSubProcessBounds()
	{
		return subProcessBounds;
	}

	public void setSubProcessBounds(Rectangle subProcessBounds)
	{
		this.subProcessBounds = subProcessBounds;
	}

	/**
	 * Returns the creation factory used to create the new EditParts.
	 * @return the creation factory
	 */
	protected CreationFactory getFactory() {
		return factory;
	}
	
	/**
	 * Sets the creation factory used to create the new edit parts.
	 * @param factory the factory
	 */
	public void setFactory(CreationFactory factory) 
	{
		this.factory = factory;
	}
	
	/**
	 * Gets the new object from the factory and returns that object.
	 * 
	 * @return the new object
	 */
	public Object getNewObject() {
		if (newObject == null)
			newObject = getFactory().getNewObject();
		return newObject;
	}

	/**
	 * Returns the type of the new object.
	 * 
	 * @return the type of the new object
	 */
	public Object getNewObjectType() {
		return getFactory().getObjectType();
	}

	public EditPart getTargetEditPart()
	{
		return targetEditPart;
	}

	public void setTargetEditPart(EditPart targetEditPart)
	{
		this.targetEditPart = targetEditPart;
	}
}
